home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 8.3 KB | 270 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: BaseShp.h
- // Release Version: $ 1.0d11 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef BASESHP_H
- #define BASESHP_H
-
- #ifndef CONSTANT_H
- #include "Constant.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWINK_H
- #include "FWInk.h"
- #endif
-
- #ifndef FWSTYLE_H
- #include "FWStyle.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWRUNTYP_H
- #include "FWRunTyp.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma import on
- #endif
- class FW_CLASS_ATTR ODFacet;
- class FW_CLASS_ATTR ODShape;
- class FW_CLASS_ATTR CDrawPart;
- class FW_CLASS_ATTR CDrawPublishLink;
- class FW_CLASS_ATTR CDrawSubscribeLink;
- class FW_CLASS_ATTR FW_CGraphicContext;
- class FW_CLASS_ATTR FW_CMouseEvent;
- class FW_CLASS_ATTR FW_CRectShape;
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma import off
- #endif
-
- class FW_CLASS_ATTR CDrawFacetClipper;
-
- //========================================================================================
- // Constants
- //========================================================================================
-
- enum ShapeType {
- kLineShape = 1,
- kRectShape = 2,
- kOvalShape = 3,
- kRRectShape = 4,
- kTextShape = 5,
- kProxyShape = 6
- };
-
- //========================================================================================
- // class CBaseShape
- //========================================================================================
-
- class FW_CLASS_ATTR CBaseShape
- {
- public:
- FW_DECLARE_CLASS
-
- public:
- virtual ~CBaseShape();
-
- virtual void Removed(Environment* ev);
- virtual void Deleted(Environment* ev);
-
- // ----- Drawing -----
- virtual void RenderShape(Environment* ev, ODFacet* facet, FW_CGraphicContext& gc) = 0;
- void RenderHandles(FW_CGraphicContext& gc);
-
- // ----- Shape setting -----
- FW_CFixed GetPenSize() const;
-
- // ----- Selection -----
- virtual FW_Boolean HitTest(Environment *ev, FW_CGraphicContext& gc, const FW_CMouseEvent& theMouseEvent) const = 0;
- FW_Boolean InSelectionRect(const FW_CRect& rect) const;
-
- short WhichHandle(FW_CGraphicContext& gc, const FW_CPoint& mouse) const;
-
- void CalcHandle(short whichHandle, FW_CRectShape* handle) const;
-
- virtual void SelectShape(Environment *ev, FW_Boolean state);
- FW_Boolean IsSelectedShape() const
- {return fSelected;}
-
- virtual void RestoreShape(Environment *ev, CDrawPart* drawPart);
-
- // ----- Creation -----
- virtual void TrackFeedback(Environment* ev, ODFacet* facet, FW_CGraphicContext& gc, const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint, FW_Boolean erase);
- virtual void SetShapeGeometry(const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint) = 0;
-
- // ----- Promises -----
- void Promised(FW_EStorageKinds storageKind, FW_Boolean state);
- FW_Boolean IsPromised(FW_EStorageKinds storageKind) const
- {return (fPromised & storageKind) != 0;}
- FW_Boolean IsPromised() const
- {return fPromised != 0;}
- void CheckPromise(Environment* ev, FW_CPart* part);
-
- // ----- Drag -----
- virtual void OffsetShape(Environment *ev, FW_CFixed xDelta, FW_CFixed yDelta) = 0;
-
- // ----- Resize -----
- FW_PStyle GetResizeStyle() const;
- virtual void ResizeFeedback(FW_CGraphicContext& gc, const FW_PInk& ink, const FW_PStyle& style,
- short whichHandle, const FW_CPoint& mouseLoc) = 0;
- virtual void GetMapRects(short whichHandle, const FW_CPoint& lastLocation,
- FW_CRect& srcRect, FW_CRect& dstRect) = 0;
- virtual void GetHandleCenter(short whichHandle, FW_CPoint& center) const = 0;
- virtual void MapShape(Environment *ev, CDrawPart* part, const FW_CRect& srcRect, const FW_CRect& dstRect) = 0;
-
- void GetUpdateBox(Environment* ev, ODShape *updateBox) const;
- void GetUpdateBox(FW_CRect& updateBox) const;
- void GetDragRect(FW_CRect& dragRect) const;
-
- virtual ODShape* CreateShapeOutline(Environment *ev) = 0;
- virtual void GetClipRegion(Environment* ev, ODShape* clipRegion) = 0;
- virtual void GetRectGeometry(FW_CRect& bounds) const = 0;
-
- virtual void SubtractToWindowClip(Environment *ev,
- CDrawFacetClipper* facetClipper,
- ODFacet* containingFacet,
- ODShape* windowClip,
- ODShape* tempShape);
-
- // ----- z-Order -----
- virtual void MovedAfter(Environment *ev, CBaseShape* shape);
- virtual void MovedBefore(Environment *ev, CBaseShape* shape);
- virtual void MovedFirst(Environment *ev);
- virtual void MovedLast(Environment *ev);
-
- // ----- Persistence -----
- virtual void Flatten(FW_CWritableStream& archive);
-
- // ----- Cache -----
- void ClearCache();
-
- // ----- Linking -----
- virtual void SetPublishLink(Environment* ev,
- CDrawPublishLink *publishLink);
- CDrawPublishLink* GetPublishLink() const
- {return fPublishLink;}
- FW_Boolean IsPublished() const
- {return fPublishLink != NULL;}
-
- virtual void SetSubscribeLink(Environment* ev,
- CDrawSubscribeLink *subscribeLink);
- CDrawSubscribeLink* GetSubscribeLink() const
- {return fSubscribeLink;}
- FW_Boolean IsSubscribed() const
- {return fSubscribeLink != NULL;}
-
- short GetExternalizationIndex()
- { return fExternalizationIndex; }
- void SetExternalizationIndex(short index)
- { fExternalizationIndex = index; }
-
- // ----- Getters/Setters -----
- virtual FW_Boolean SetFrozen(FW_Boolean state);
- virtual FW_Boolean IsFrozen() const;
-
- FW_Boolean HasFillStyle() const
- {return (fRenderVerb & kFillOnly) != 0;}
- FW_Boolean FillOnly() const
- {return fRenderVerb == kFillOnly;}
- FW_Boolean HasFrameStyle() const
- {return (fRenderVerb & kFrameOnly) != 0;}
- FW_Boolean FrameOnly() const
- {return fRenderVerb == kFrameOnly;}
- FW_Boolean HasFrameAndFillStyle() const
- {return (fRenderVerb == kFillFrame);}
-
- void GetColor(FW_Boolean fill, FW_CColor& color);
- FW_PPattern GetPattern(FW_Boolean fill);
- unsigned short GetRenderVerb()
- { return fRenderVerb; };
-
- short GetNumberOfHandles() const
- {return fNumberOfHandles;}
- ShapeType GetShapeType() const
- {return (ShapeType)fShapeType;}
-
- void SetFrameInk(const FW_PInk& ink)
- {fFrameInk = ink;}
- void SetFrameStyle(const FW_PStyle& style)
- {fFrameStyle = style;}
- void SetFillInk(const FW_PInk& ink)
- {fFillInk = ink;}
- void SetFillStyle(const FW_PStyle& style)
- {fFillStyle = style;}
-
- void ChangeFrameColor(Environment* ev, CDrawPart* part, const FW_CColor& color);
- void ChangeFramePattern(Environment* ev, CDrawPart* part, const FW_PPattern& pattern);
-
- void ChangeFillColor(Environment* ev, CDrawPart* part, const FW_CColor& color);
- void ChangeFillPattern(Environment* ev, CDrawPart* part, const FW_PPattern& pattern);
-
- void ChangePenSize(Environment* ev, CDrawPart* part, FW_CFixed newPenSize);
- virtual void ChangeRenderVerb(Environment* ev, CDrawPart* part, unsigned short renderVerb);
-
- FW_PInk UnshareInk(const FW_PInk& ink) const;
- FW_PStyle UnshareStyle(const FW_PStyle& style) const;
-
- void AdjustRectForPenSize(FW_CRect& rect, FW_CFixed penSize) const;
-
- // ----- Archiving -----
- static void* Read(FW_CReadableStream& archive);
- static void Write(FW_CWritableStream& archive, const void* objectRep);
-
- protected:
- CBaseShape(short numberOfHandles, unsigned short shapeType, unsigned short renderVerb);
- CBaseShape(FW_CReadableStream& archive);
-
- void InitStatic();
-
- public:
- static FW_CRectShape *gWorkingHandle;
- static unsigned long gShapeCount;
-
- protected:
- unsigned short fPromised;
-
- FW_PInk fFrameInk;
- FW_PInk fFillInk;
- FW_PStyle fFrameStyle;
- FW_PStyle fFillStyle;
-
- unsigned short fRenderVerb;
-
- unsigned short fShapeType;
-
- FW_Boolean fSelected;
- short fNumberOfHandles;
- CDrawPublishLink* fPublishLink;
- CDrawSubscribeLink* fSubscribeLink;
- short fExternalizationIndex; // used by links to identify their shapes
- };
-
- #endif